/*
 * @Author: your name
 * @Date: 2019-12-02 21:51:29
 * @LastEditTime: 2019-12-10 18:24:13
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \pc\src\pages\OperatingPlan\ContractPlan\ProductTypeDetail\models\versions.js
 */
import * as api from '@/services/ContractPlanMgr';

const Model = {
  namespace: 'ContractPlanDetailVersions',
  state: {
    data: [],
  },
  effects: {
    *fetch({ payload, callback }, { call, put }) {
      const response = yield call(api.getSignFullPathUsingGET, payload);
      if (response && response.data) {
        yield put({
          type: 'save',
          payload: { data: response.data },
        });
      } else {
        yield put({
          type: 'save',
          payload: { data: [] },
        });
      }

      if (callback && typeof callback === 'function') {
        callback(response.data);
      }
    },
  },
  reducers: {
    clear() {
      return {
        data: [],
      };
    },
    save(state, action) {
      return {
        ...state,
        ...action.payload,
      };
    },
  },
};
export default Model;
